package com.patterns.singleton;

/**
 * 双重检测锁式单例模式(不建议使用)
 * @author huangke
 *
 */
public class SingletonDemo3 {
	private static SingletonDemo3 instance;
	
	private SingletonDemo3(){
		
	}
	
	public static SingletonDemo3 getInstance(){
		if(null == instance){
			SingletonDemo3 sd;
			synchronized (SingletonDemo3.class) {
				sd = instance;
				if(null == sd){
					synchronized (SingletonDemo3.class) {
						if(null == sd){
							sd = new SingletonDemo3();
						}
					}
					instance = sd;
				}
			}
		}
		return instance;
	}
}
